package view.wizard;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;

public class Wiz1 extends WizardView {
	
	private TextField field = new TextField("Entre com seu nome:","",15,TextField.ANY);
	
	private Form form;
	
	private String name;
	
	protected void createView() {
		form = new Form("Passo 2");
		form.append(field);
	}

	public Displayable getScreen() {
		return form;
	}

	protected void initModel() {
		name = null;
	}

	public int onEnter(int direction) {
		return OK;
	}

	public int onLeave(int direction) {
		if(direction==DIR_FORWARD) {
			String name_field = field.getString();
			if(name_field==null || name_field.length()==0) {
				errorMsg("ERRO", "Entre com um nome");
				return REJECT;
			}
			name = name_field;
		}
		return OK;
	}

	protected void updateView() {
		field.setString(name);
	}

	protected void viewCommandAction(Command cmd, Displayable display) {
		
	}

}
